package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.common.ActivationStatus;
import com.ap.core.domain.MerchantDistributorDetailsId;
import com.ap.core.message.managemerchant.info.RequestMerchantRegistrationTypeInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.OriginalInfo;

/**
 * User: Dilip.Sridhar
 * Check for Merchant related to the distributor where the merchant is in a "DEREGISTERED" state.
 */
public class RV0023Rule extends AbstractMerchantDistributorCheckRule<RequestMerchantRegistrationTypeInfo, OriginalInfo>  {
	
	@Override
    public boolean validate(MessageValidationInfo<RequestMerchantRegistrationTypeInfo,OriginalInfo> infoObject) {
		final RequestMerchantRegistrationTypeInfo requestMerchantRegistrationTypeInfo = infoObject.getBoundObject();
        final String distributorIdentification = requestMerchantRegistrationTypeInfo.getDistributorId();       
        final MerchantDistributorDetailsId merchantDistributorDetailsId = new MerchantDistributorDetailsId(requestMerchantRegistrationTypeInfo.getMerchant().getMerchantId(), distributorIdentification);
        return isMerchantAssociatedWithDistributorInGivenState(merchantDistributorDetailsId, ActivationStatus.DEREGISTERED);
    }

}
